package collention;

import java.util.ArrayList;
import java.util.Collection;

/**
 * @Classname: CollectionDemo3
 * @Author: bromide
 * @CreateTime: 2022/4/2--17:33
 * @Version: V1.0
 * @Description: 集合只能保存引用类型元素，并且保存的是元素的引用(地址)
 */
public class CollectionDemo3 {
    public static void main(String[] args) {
        Point p = new Point(1, 2);
        Collection c = new ArrayList();
        c.add(p);
        System.out.println("c:" + c);//(1,2)
        System.out.println("p:" + p);//[(1,2)]

        p.setX(2);
        System.out.println("c:" + c);//(2,2)
        System.out.println("p:" + p);//[(2,2)]

    }
}
